﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace Util
{
    [Serializable]
    public class Result
    {
        #region 是否操作成功
        private bool isSuccess = false;
        public bool IsSuccess
        {
            get
            {
                return isSuccess;
            }
            set
            {
                isSuccess = value;
            }
        }
        #endregion

        #region 信息
        private string msg ;
        public string Msg
        {
            get
            {
                return msg;
            }
            set
            {
                msg = value;
            }
        }
        #endregion

        #region 返回的数据集
        private DataSet dataResult;
        public DataSet DataResult
        {
            get
            {
                return dataResult;
            }
            set
            {
                dataResult = value;
            }
        }
        #endregion 

        #region 分页信息
        private PageInfo _pageInfo;
        public PageInfo pageInfo
        {
            get
            {
                return _pageInfo;
            }
            set
            {
                _pageInfo = value;
            }
        }
        #endregion 
    }

    [Serializable]
    public class PageInfo
    {
        public PageInfo(int iCurrentPage, int iPageSize, int iRecordCount)
        {
            this.CurrentPage = iCurrentPage;
            this.PageSize = iPageSize;
            this.RecordCount = iRecordCount;

            if (PageSize != 0)
            {

                if (this.RecordCount % PageSize == 0)
                {
                    this.pageCount = this.RecordCount / this.PageSize;
                }
                else
                {
                    this.pageCount = this.RecordCount / this.PageSize + 1;
                }
            }
        }
        #region 记录总数
        private int recordCount = 0;
        public int RecordCount
        {
            get
            {
                return recordCount;
            }
            set
            {
                recordCount = value;
            }
        }
        #endregion
        #region 总页数
        private int pageCount = 0;
        public int PageCount
        {
            get
            {
                return pageCount;
            }
        }
        #endregion
        #region 当前页码
        private int currentPage = 0;
        public int CurrentPage
        {
            get
            {
                return currentPage;
            }
            set
            {
                currentPage = value;
            }
        }
        #endregion

        #region 每页记录数
        private int pageSize = 0;
        public int PageSize
        {
            get
            {
                return pageSize;
            }
            set
            {
                pageSize = value;
            }
        }
        #endregion
        public static Result Parse(Object obj)
        {
            return (Result)obj;
        }
    }
}
